/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author rodrigo
 */
@Entity
@Table(name = "Alternativa")
@NamedQueries({
    @NamedQuery(name = "Alternativa.findAll", query = "SELECT a FROM Alternativa a"),
    @NamedQuery(name = "Alternativa.findByAlternativaId", query = "SELECT a FROM Alternativa a WHERE a.alternativaId = :alternativaId"),
    @NamedQuery(name = "Alternativa.findByAlternativa", query = "SELECT a FROM Alternativa a WHERE a.alternativa = :alternativa"),
    @NamedQuery(name = "Alternativa.findByAlternativaCorreta", query = "SELECT a FROM Alternativa a WHERE a.alternativaCorreta = :alternativaCorreta")})
public class Alternativa implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "alternativa_id")
    private Integer alternativaId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "alternativa")
    private String alternativa;
    @Column(name = "alternativa_correta")
    private Boolean alternativaCorreta;
    @ManyToMany(mappedBy = "alternativaList")
    private List<Gabarito> gabaritoList;
    @JoinColumn(name = "questao_id", referencedColumnName = "questao_id")
    @ManyToOne(optional = false)
    private Questao questaoId;

    public Alternativa() {
    }

    public Alternativa(Integer alternativaId) {
        this.alternativaId = alternativaId;
    }

    public Alternativa(Integer alternativaId, String alternativa) {
        this.alternativaId = alternativaId;
        this.alternativa = alternativa;
    }

    public Integer getAlternativaId() {
        return alternativaId;
    }

    public void setAlternativaId(Integer alternativaId) {
        this.alternativaId = alternativaId;
    }

    public String getAlternativa() {
        return alternativa;
    }

    public void setAlternativa(String alternativa) {
        this.alternativa = alternativa;
    }

    public Boolean getAlternativaCorreta() {
        return alternativaCorreta;
    }

    public void setAlternativaCorreta(Boolean alternativaCorreta) {
        this.alternativaCorreta = alternativaCorreta;
    }

    public List<Gabarito> getGabaritoList() {
        return gabaritoList;
    }

    public void setGabaritoList(List<Gabarito> gabaritoList) {
        this.gabaritoList = gabaritoList;
    }

    public Questao getQuestaoId() {
        return questaoId;
    }

    public void setQuestaoId(Questao questaoId) {
        this.questaoId = questaoId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (alternativaId != null ? alternativaId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Alternativa)) {
            return false;
        }
        Alternativa other = (Alternativa) object;
        if ((this.alternativaId == null && other.alternativaId != null) || (this.alternativaId != null && !this.alternativaId.equals(other.alternativaId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Alternativa[ alternativaId=" + alternativaId + " ]";
    }
    
}
